package com.itheima.mapper;

import com.itheima.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {

    ShoppingCart findUidAndDidAndSid(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void save(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number=#{number} where id=#{id} ")
    void update(ShoppingCart shoppingCartnew);

    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> fincartByUserId(long userId);

    @Delete("delete from shopping_cart where user_id=#{userId}")
    void delete(long userid);


//查找购物车存在的数量
    int findShoppingCartNumber(ShoppingCart shoppingCart);
    //数量减一





    ShoppingCart findBySCId(ShoppingCart shoppingCart);

@Update("update shopping_cart set number=#{number} where id=#{id} ")
    void updateByNumber(ShoppingCart shoppingCart);

@Delete("delete from shopping_cart where id=#{id}")
    void deleteByDishidOrSetmealid(ShoppingCart shoppingCart);

//    @Select("select * from where user_id=#{userId} ")
    ShoppingCart findSCByUserId(ShoppingCart shoppingCart);
}
